package com.mini.service;

import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.mini.conditon.BusinessConditionNew;
import com.mini.constant.RedisKeyConst;
import com.mini.model.*;
import com.mini.repository.BusinessPlanHistoryRepository;
import com.mini.repository.BusinessPlanInfoRepository;
import com.mini.repository.BusinessPlanPageSiteRRepository;
import com.mini.res.BusinessPlanRES;
import com.mini.res.BusinessPlanSitePageRRES;
import com.mini.util.MatcherRule;
import com.mini.vo.BusinessPlanVO;
import com.mini.vo.DeptVO;
import com.mini.vo.FullDeptVo;
import com.mini.vo.PageResultVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

@Slf4j
@Service
public class BusinessPlanService extends BaseService {
    @Autowired
    private BusinessBaseService businessBaseService;
    @Autowired
    private BussinessPageInfoService bussinessPageInfoService;
    @Autowired
    private BusinessPlanInfoRepository planInfoRepository;
    @Autowired
    private BusinessPlanPageSiteRRepository planPageSiteRRepository;
    @Autowired
    private BusinessPlanHistoryRepository planHistoryRepository;
    @Autowired
    private RedisTemplate redisTemplate;


    @Autowired
    private MiniAdminService miniAdminService;


    @Transactional
    public boolean batchUpdate(List<BusinessPlanVO> businessPlanVOLists) {
        for (BusinessPlanVO businessPlanVO : businessPlanVOLists) {
            if (null == businessPlanVO.getNextDayLessonSite() || null == businessPlanVO.getPlanSite()) {
                log.info("参数错误 ={}", businessPlanVO);
                return true;
            }
            log.info("businessPlanVO={}", businessPlanVO);
            update(businessPlanVO.getPlanSite(), businessPlanVO.getNextDayLessonSite(), businessPlanVO.getFzId());
        }
        return false;
    }

    @Transactional
    public boolean batchAddPlan(Long userId, List<BusinessPlanVO> businessPlanVOLists) {
        String baseKey = RedisKeyConst.getBusinessNewFlag("plan", userId);
        redisTemplate.delete(baseKey);
        int len = businessPlanVOLists.size();
        for (int i = len - 1; i >= 0; i--) {
            BusinessPlanVO businessPlanVO = businessPlanVOLists.get(i);
            if ((org.apache.commons.lang.StringUtils.isBlank(businessPlanVO.getPageSite())) || org.apache.commons.lang.StringUtils.isBlank(businessPlanVO.getPlanName()) ||
                    null == businessPlanVO.getFzId() || null == businessPlanVO.getLessonSite()) {
                log.info("参数错误 ={}", businessPlanVO);
                return true;
            }
            BusinessPlanSitePageR businessPlanSitePageR = add(businessPlanVO);
            redisTemplate.opsForSet().add(baseKey, businessPlanSitePageR.getPlanSite());
        }
        redisTemplate.expire(baseKey, 30, TimeUnit.DAYS);
        return false;
    }

    @Transactional(rollbackFor = Exception.class)
    public BusinessPlanSitePageR add(BusinessPlanVO businessPlanVO) {
        BusinessPlanSitePageR byPlanName = planPageSiteRRepository.findByPlanName(businessPlanVO.getPlanName());
        if (null != byPlanName) {
            throw new RuntimeException("planName_" + businessPlanVO.getPlanName() + "_计划名称已经存在");
        }
        // 查询页面信息
        String pageSite = businessPlanVO.getPageSite();
        if (pageSite.startsWith("ym") || pageSite.startsWith("YM")) {
            pageSite = pageSite.substring(2);
        }
        long pageSiteId = 0;
        try {
            pageSiteId = Long.parseLong(pageSite);
        } catch (NumberFormatException e) {
            throw new RuntimeException("pageSite_" + businessPlanVO.getPageSite() + "_页面站点格式错误");
        }

        BussinessPageInfo bussinessPageInfo = bussinessPageInfoService.findById(pageSiteId);
        if (null == bussinessPageInfo) {
            throw new RuntimeException("pageSite_" + businessPlanVO.getPageSite() + "_落地页不存在");
        }
        // 查询小课站点信息
        BusinessBaseInfo businessBaseInfo = businessBaseService.getByMiniLessonId(businessPlanVO.getLessonSite());
        if (null == businessBaseInfo) {
            throw new RuntimeException("lessonSite_" + businessPlanVO.getLessonSite() + "_小课站点不存在");
        }
        // 校验负责人和渠道
        if (!businessBaseInfo.getChannelCode().equals(bussinessPageInfo.getChannelCode())) {
            throw new RuntimeException("pageSite_" + businessPlanVO.getPageSite() + "_请输入与原小课站点渠道相同的页面站点");
        }
        if (bussinessPageInfo.getFzId().longValue() != businessPlanVO.getFzId()) {
            throw new RuntimeException("pageSite_" + businessPlanVO.getPageSite() + "_请输入自己创建的页面站点");
        }
        if (businessBaseInfo.getFzId().longValue() != businessPlanVO.getFzId()) {
            throw new RuntimeException("lessonSite_" + businessPlanVO.getLessonSite() + "_请输入自己创建的小课站点");
        }
        // 校验小课业务和传统业务 绑定模版 小课业务可以绑定模板1/2/3/4 传统业务只能绑定模板7

//        if (bussinessPageInfo.getPageType() != null && bussinessPageInfo.getPageType() == 2) {
//            throw new RuntimeException("pageSite_" + businessPlanVO.getPageSite() + "_小程序类模版只能绑小课业务");
//        }

        if ((bussinessPageInfo.getPageType() != null && bussinessPageInfo.getPageType() == 2) && !"WX".equals(businessBaseInfo.getChannelCode()) && !"GDT".equals(businessBaseInfo.getChannelCode())) {
            throw new RuntimeException("pageSite_" + businessPlanVO.getPageSite() + "_小程序类模版只能用于微信渠道");
        }

        if (bussinessPageInfo.getPageType() == null || bussinessPageInfo.getPageType() == 0) {
            throw new RuntimeException("pageSite_" + businessPlanVO.getPageSite() + "_小课业务可以绑定模板1/2/3/4 传统业务只能绑定模板7");
        }
        // 校验传统模式AB

        if (!businessBaseInfo.getSiteModel().equals(getModeCode(bussinessPageInfo.getSiteModel()))) {
            throw new RuntimeException("pageSite_" + businessPlanVO.getPageSite() + "_AB模式不匹配");
        }

        List<BusinessPlanSitePageR> lessonSiteList = planPageSiteRRepository.findAllByLessonSite(businessPlanVO.getLessonSite());
        if(CollectionUtils.isNotEmpty(lessonSiteList)){
            throw new RuntimeException("lessonSite_" + businessPlanVO.getLessonSite() + "_该飞天站点已被别的计划名称绑定");
        }
        List<BusinessPlanSitePageR> nextDayLessonSites = planPageSiteRRepository.findAllByNextDayLessonSite(businessPlanVO.getLessonSite());
        if(CollectionUtils.isNotEmpty(nextDayLessonSites)){
            throw new RuntimeException("lessonSite_" + businessPlanVO.getLessonSite() + "_该飞天站点已作为次日飞天站点被别的计划名称绑定");
        }
        // 保存计划基础信息
        BusinessPlanInfo save = planInfoRepository.save(new BusinessPlanInfo(businessPlanVO.getPlanName()));
        // 保存计划关系
        BusinessPlanSitePageR planPageSiteR = new BusinessPlanSitePageR();
        String mkt_chm = "&mkt_chn=" + bussinessPageInfo.getChannelCode();
        if (bussinessPageInfo.getPageType() != null && bussinessPageInfo.getPageType() == 2) {
            mkt_chm = "";
        }
        planPageSiteR.setTouFangUrl(bussinessPageInfo.getUrl() + "?p=" + save.getPlanSite() + "_" + bussinessPageInfo.getJsUuid() + mkt_chm+"&bstype=c");
        planPageSiteR.setChannelCode(businessBaseInfo.getChannelCode());
        planPageSiteR.setChannelName(businessBaseInfo.getChannelName());
        planPageSiteR.setChannelId(businessBaseInfo.getChannelId());
        planPageSiteR.setFzId(businessBaseInfo.getFzId());
        planPageSiteR.setFzName(businessBaseInfo.getFzName());
        if(StringUtils.isNotEmpty(businessBaseInfo.getQuantumGroupId())){

            List<String> groupIdList = new ArrayList<>(Splitter.on(",").splitToList(businessBaseInfo.getQuantumGroupId()));
            Collections.sort(groupIdList);
            planPageSiteR.setGroupIds(String.join(",", groupIdList));
        }
        planPageSiteR.setGroupNames(businessBaseInfo.getQuantumGroupName());
        FullDeptVo userInfo = miniAdminService.getUserFullDept(businessBaseInfo.getFzId());
//        log.info("FullDeptVo={}", JSONObject.toJSONString(userInfo));
        if(userInfo != null){

            planPageSiteR.setWorkRoomId(userInfo.getWorkRoomId());
            planPageSiteR.setWorkRoomName(userInfo.getWorkRoomName());
        }
//      planPageSiteR.setNextDayLessonSite(null);
        planPageSiteR.setLessonSite(businessBaseInfo.getMiniLessonId());
        planPageSiteR.setPlanName(businessPlanVO.getPlanName());
        planPageSiteR.setPageSite(Long.parseLong(pageSite));
        planPageSiteR.setPlanSite(save.getPlanSite());
        planPageSiteR.setLessonId("");
//        BusinessResult<Integer> deptFullName = qdcyDmpServerClient.getDeptFullName(reqSign,businessPlanVO.getPlanName());
//        if (0 == deptFullName.getCode()) {
//            if (-1 == deptFullName.getData()) {
//                if (businessBaseInfo.getChannelId() == 1) {
//                    planPageSiteR.setStatus(-2);
//                } else {
//                    planPageSiteR.setStatus(-3);
//                }
//            } else {
//                planPageSiteR.setStatus(deptFullName.getData());
//            }
//        }
        planPageSiteRRepository.save(planPageSiteR);
        return planPageSiteR;
    }

    private Integer getModeCode(String modeStr) {
        if ("A".equals(modeStr)) {
            return 1;
        } else if ("B".equals(modeStr)) {
            return 2;
        } else {
            return 0;
        }
    }

    public String getCharAndNumR(int length) {
        StringBuffer valSb = new StringBuffer();
        String charStr = "0123456789abcdefghijklmnopqrstuvwxyz";
        for (int i = 0; i < length; i++) {
            valSb.append(charStr.charAt(new Random().nextInt(36)));
        }
        return valSb.toString();
    }

    public void update(Long planSite, Long newDayLessonSite, Long fzId) {
        BusinessPlanSitePageR planSitePageR = getRByPlanSite(planSite);
        if (null == planSitePageR) {
            throw new RuntimeException("planSite_" + planSite + "_计划站点不存在");
        }

        BusinessBaseInfo businessBaseInfo = businessBaseService.getByMiniLessonId(newDayLessonSite);
        if (null == businessBaseInfo) {
            throw new RuntimeException("newDayLessonSite_" + newDayLessonSite + "_小课站点不存在");
        }
        if (planSitePageR.getChannelId() != businessBaseInfo.getChannelId().intValue()) {
            throw new RuntimeException("newDayLessonSite_" + newDayLessonSite + "_请输入与原小课站点渠道相同的站点");
        }
        if (planSitePageR.getFzId().longValue() != businessBaseInfo.getFzId() || businessBaseInfo.getFzId() != fzId.longValue()) {
            throw new RuntimeException("planSite_" + planSite + "_请输入自己创建的计划站点");
        }
        // 查询小课站点信息

        // 查询页面信息
        Long pageSiteId = planSitePageR.getPageSite();
        BussinessPageInfo bussinessPageInfo = bussinessPageInfoService.findById(pageSiteId);
        if (null == bussinessPageInfo) {
            throw new RuntimeException("newDayLessonSite_" + newDayLessonSite + "_落地页不存在");
        }
        // 校验小课业务和传统业务 绑定模版 小课业务可以绑定模板1/2/3/4 传统业务只能绑定模板7

        if (bussinessPageInfo.getPageType() == 0) {
            throw new RuntimeException("newDayLessonSite_" + newDayLessonSite + "_小课业务可以绑定模板1/2/3/4 传统业务只能绑定模板7");
        }
        // 校验传统模式AB

        if (!businessBaseInfo.getSiteModel().equals(getModeCode(bussinessPageInfo.getSiteModel()))) {
            throw new RuntimeException("newDayLessonSite_" + newDayLessonSite + "_AB模式不匹配");
        }
        List<BusinessPlanSitePageR> nextDayLessonSiteList = planPageSiteRRepository.findAllByNextDayLessonSite(newDayLessonSite);
        List<BusinessPlanSitePageR> planSitePageRS = nextDayLessonSiteList.stream().filter(businessPlanSitePageR -> !businessPlanSitePageR.getId().equals(planSitePageR.getId())).collect(Collectors.toList());
        if(CollectionUtils.isNotEmpty(planSitePageRS)){
            throw new RuntimeException("nextDayLessonSite_" + newDayLessonSite + "_该次日飞天站点已被别的(次日)计划站点绑定");
        }
        final List<BusinessPlanSitePageR> allByLessonSite = planPageSiteRRepository.findAllByLessonSite(newDayLessonSite);
        if(CollectionUtils.isNotEmpty(allByLessonSite)){
            throw new RuntimeException("nextDayLessonSite_" + newDayLessonSite + "_该次日飞天站点已被别的飞天站点绑定");
        }

        planSitePageR.setNextDayLessonSite(newDayLessonSite);
        // 更新计划站点信息
        planPageSiteRRepository.save(planSitePageR);
        redisTemplate.delete(RedisKeyConst.getPlanSitePage(planSite));

        redisTemplate.opsForSet().add(RedisKeyConst.PLAN_NEXTDAYLESSONSITE, planSite + "_" + newDayLessonSite);
    }

    public BusinessPlanInfo getByPlanSite(Long planSite) {
        String key = RedisKeyConst.getPlanInfo(planSite);
        Object o = redisTemplate.opsForValue().get(key);
        if (null == o) {
            BusinessPlanInfo one = planInfoRepository.findOne(planSite);
            if (null != one) {
                redisTemplate.opsForValue().set(key, one, 6, TimeUnit.DAYS);
            }
            return one;
        }
        return (BusinessPlanInfo) o;
    }

    public BusinessPlanSitePageR getRByPlanSite(Long planSite) {
        String key = RedisKeyConst.getPlanSitePage(planSite);
        Object o = redisTemplate.opsForValue().get(key);
        if (null == o) {
            BusinessPlanSitePageR one = planPageSiteRRepository.findByPlanSite(planSite);
            if (null != one) {
                redisTemplate.opsForValue().set(key, one, 2, TimeUnit.DAYS);
            }
            return one;
        }

        return (BusinessPlanSitePageR) o;
    }

    public BusinessPlanSiteHistory getHistoryByPlanSite(Long planSite) {
        String key = RedisKeyConst.getPlanHisotory(planSite);
        Object o = redisTemplate.opsForValue().get(key);
        if (null == o) {
            BusinessPlanSiteHistory one = planHistoryRepository.findByPlanSite(planSite);
            if (null != one) {
                redisTemplate.opsForValue().set(key, one, 2, TimeUnit.DAYS);
            }
            return one;
        }

        return (BusinessPlanSiteHistory) o;
    }

    public void saveR(BusinessPlanSitePageR planSitePageR) {
        planPageSiteRRepository.save(planSitePageR);
        redisTemplate.delete(RedisKeyConst.getPlanSitePage(planSitePageR.getPlanSite()));
    }

    public void saveHistory(BusinessPlanSiteHistory planSiteHistory) {
        planHistoryRepository.save(planSiteHistory);
        redisTemplate.delete(RedisKeyConst.getPlanHisotory(planSiteHistory.getPlanSite()));
    }

    public PageResultVO<BusinessPlanSitePageRRES> page(BusinessConditionNew condition, Long userId, boolean export) {
        PageResultVO<BusinessPlanSitePageRRES> resultVO = new PageResultVO<>();
        List<String> orderKeys = new ArrayList<>();
        if (StringUtils.isNotEmpty(condition.getSortColumn())) {
            orderKeys.add(condition.getSortColumn());
            orderKeys.add("id");
        }
        Pageable pageable = null;
        Sort sort = null;
        if (StringUtils.isNotEmpty(condition.getSortType()) && StringUtils.isNotEmpty(condition.getSortColumn())) {
            sort = new Sort(Sort.Direction.valueOf(condition.getSortType()), orderKeys);
        }
        pageable = buildPageRequest(condition.getPageNumber(), condition.getPageSize(), sort);
        log.info("pageable={}", pageable);
        Page<BusinessPlanSitePageR> page = planPageSiteRRepository.findAll(new Specification<BusinessPlanSitePageR>() {
            @Override
            public Predicate toPredicate(Root<BusinessPlanSitePageR> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
                List<Predicate> predicates = new ArrayList<>();
                if (StringUtils.isNotBlank(condition.getPlanSite())) {
                    if (MatcherRule.isInteger(condition.getPlanSite()) && 0 != Long.parseLong(condition.getPlanSite())) {
//                        predicates.add(criteriaBuilder.equal(root.get("planSite").as(Long.class), condition.getPlanSite()));
                        predicates.add(criteriaBuilder.or(criteriaBuilder.like(root.get("planSite").as(String.class), "%" + condition.getPlanSite() + "%"),
                                criteriaBuilder.like(root.get("planName").as(String.class), "%" + condition.getPlanSite() + "%")));
                    } else {
                        predicates.add(criteriaBuilder.like(root.get("planName").as(String.class), "%" + condition.getPlanSite() + "%"));
                    }
                }

                if (condition.getFzId() != null && 0 != condition.getFzId().longValue()) {
                    predicates.add(criteriaBuilder.equal(root.get("fzId").as(Long.class), condition.getFzId()));
                } else {
                    if (condition.getCreateUserId() != null && 0 != condition.getCreateUserId().intValue()) {
                        List<Long> userids = scopedAdvertisingUserIds(condition.getCreateUserId());
                        CriteriaBuilder.In<Long> in = criteriaBuilder.in(root.get("fzId"));
                        Iterator<Long> it = userids.iterator();
                        while (it.hasNext()) {
                            in.value(it.next());
                        }
                        predicates.add(in);
                    }
                }
                if (StringUtils.isNotBlank(condition.getArmyGroupId())) {
                    List<String> groupIdList = new ArrayList<>(Splitter.on(",").splitToList(condition.getArmyGroupId()));
                    Collections.sort(groupIdList);
                    predicates.add(criteriaBuilder.equal(root.get("armyGroupId").as(String.class), String.join(",", groupIdList)));
                }

                if (null != condition.getChannelId()) {
                    predicates.add(criteriaBuilder.equal(root.get("channelId").as(String.class), condition.getChannelId()));
                }
                if (StringUtils.isNotBlank(condition.getMiniLesson())) {
                    predicates.add(criteriaBuilder.equal(root.get("lessonSite").as(Long.class), condition.getMiniLesson()));
                }

                //查询传统和小课业务
                Integer siteType = condition.getSiteType();
                if (siteType != null && siteType >= 0) {
                    List<BusinessBaseInfo> relist = businessBaseService.getBusinessBaseInfoBySiteModel(siteType);
                    CriteriaBuilder.In<Long> in = criteriaBuilder.in(root.get("lessonSite").as(Long.class));
                    if (relist != null && relist.size() > 0) {
                        for (BusinessBaseInfo businessBaseInfo : relist) {
                            in.value(businessBaseInfo.getMiniLessonId());
                        }
                        predicates.add(in);
                    }
                }
                if (StringUtils.isNotBlank(condition.getPageId())) {
                    predicates.add(criteriaBuilder.equal(root.get("pageSite").as(Long.class), Long.parseLong(condition.getPageId())));
                }
                return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
            }
        }, pageable);
        List<BusinessPlanSitePageR> content = page.getContent();
        List<Long> lessonSiteList = Lists.newArrayList();
        List<BusinessPlanSitePageRRES> planSitePageRRESList = Lists.newArrayList();
        for (BusinessPlanSitePageR planSitePageR : content) {
            lessonSiteList.add(planSitePageR.getLessonSite());

            BusinessPlanSitePageRRES planSitePageRRES = new BusinessPlanSitePageRRES();
            BeanUtils.copyProperties(planSitePageR, planSitePageRRES);
            Set<Integer> members = redisTemplate.opsForSet().members(RedisKeyConst.getBusinessNewFlag("plan", userId));
            log.debug("members={}", members);
            if (members.contains(planSitePageRRES.getPlanSite().intValue())) {
                planSitePageRRES.setNewFlag((byte) 1);
            }
            planSitePageRRESList.add(planSitePageRRES);
        }


        for (BusinessPlanSitePageRRES temp : planSitePageRRESList) {
            BusinessBaseInfo businessBaseInfo = businessBaseService.getByMiniLessonId(temp.getLessonSite());
            if (businessBaseInfo != null) {
                temp.setSiteType(businessBaseInfo.getSiteType() == null ? 0 : businessBaseInfo.getSiteType());
            }
        }
        resultVO.setTotal(page.getTotalElements());
        resultVO.setRows(planSitePageRRESList);
        return resultVO;
    }


    public HashMap<Long, List<String>> listPlanName(List<Long> lessonSiteList) {
        List<BusinessPlanSitePageR> byLessonSiteIn = planPageSiteRRepository.findByLessonSiteIn(lessonSiteList);
        HashMap<Long, List<String>> planNameMap = new HashMap<>();
        for (BusinessPlanSitePageR planSitePageR : byLessonSiteIn) {
            if ("DY".equalsIgnoreCase(planSitePageR.getChannelCode()) || "KS".equalsIgnoreCase(planSitePageR.getChannelCode())) {//只查询抖音和快手的数据

            } else {
                continue;
            }
            List<String> planNameListByLessonId = planNameMap.get(planSitePageR.getLessonSite());
            if (null == planNameListByLessonId || planNameListByLessonId.size() == 0) {
                planNameMap.put(planSitePageR.getLessonSite(), Lists.newArrayList(planSitePageR.getPlanName()));
            } else {
                planNameListByLessonId.add(planSitePageR.getPlanName());
                planNameMap.put(planSitePageR.getLessonSite(), planNameListByLessonId);
            }
        }
        return planNameMap;
    }

    public List<BusinessPlanSitePageR> listPlanInfo(Long lessonSiteId) {
        return planPageSiteRRepository.findAllByLessonSite(lessonSiteId);
    }


    public Map<String, DeptVO> getDeptNameMap(String groupids) {
        String[] a = groupids.split(",");
        Set p = new HashSet();
        for (String s : a) {
            p.add(Long.parseLong(s));
        }
        Map<String, DeptVO> remap = new HashMap<>();
        List<DeptVO> relist = miniAdminService.getDeptsBatch(p);
        for (DeptVO deptVO : relist) {
            remap.put(deptVO.getId() + "", deptVO);
        }
        return remap;

    }

    public BusinessPlanRES getPlanSiteRelationInfo(Long planSite) {

        BusinessPlanSitePageR planSitePageR = getRByPlanSite(planSite);
        if (null == planSitePageR) {
            throw new RuntimeException("计划站点不存在");
        }
        BussinessPageInfo pageInfo = bussinessPageInfoService.findById(planSitePageR.getId());
        if (null == pageInfo) {
            throw new RuntimeException("落地页不存在");
        }
        BusinessBaseInfo businessBaseInfo = businessBaseService.getByMiniLessonId(planSitePageR.getLessonSite());
        if (null == businessBaseInfo) {
            throw new RuntimeException("小课站点不存在");
        }
        return new BusinessPlanRES(planSite, planSitePageR.getLessonSite(), "", planSitePageR.getChannelCode(), pageInfo.getOcpmType());
    }

}
